﻿// Decompiled with JetBrains decompiler
// Type: DnProcessSimulateCommands.DigitalTwinAlignment.CCoDigitalTwinAlignmentBeamCmd
// Assembly: DnProcessSimulateCommands, Version=2402.0.0.890, Culture=neutral, PublicKeyToken=null
// MVID: A885D881-AEDF-447E-852A-6F13102E089C
// Assembly location: C:\Program Files\Tecnomatix_2402\eMPower\DotNetCommands\DnProcessSimulateCommands.dll

using System.Windows.Forms;
using System.Windows.Input;
using Tecnomatix.Engineering;
using Tecnomatix.Engineering.Ui;


namespace DnProcessSimulateCommands.DigitalTwinAlignment;

public class CCoDigitalTwinAlignmentBeamCmd : TxToggleButtonCommand
{
  private readonly CApEnabler _enabler = new CApEnabler();
  private CApLifetimeManager _lifetimeManager = new CApLifetimeManager();

  public virtual string Description => DnProcessSimulateCommands.DigitalTwinAlignment.Resources.Resources.BeamCommandDescription;

  public virtual string Category => DnProcessSimulateCommands.DigitalTwinAlignment.Resources.Resources.CommandCategory;

  public virtual string Name => DnProcessSimulateCommands.DigitalTwinAlignment.Resources.Resources.BeamCommandName;

  public virtual string Tooltip => DnProcessSimulateCommands.DigitalTwinAlignment.Resources.Resources.BeamCommandTooltip;

  public virtual string Bitmap => "DigitalTwinAlignment.Resources.DTA.bmp";

  public virtual string LargeBitmap => "DigitalTwinAlignment.Resources.DTA_LARGE.png";

  public virtual bool Licensed => TxCommandLicenser.DigitalTwinAlignmentLicense;

  public virtual ITxCommandEnabler CommandEnabler => (ITxCommandEnabler) this._enabler;

  public virtual bool Push => this._lifetimeManager.IsRunning;

  public virtual ITxImage Image => (ITxImage) TxImageManager.GetImageByKey("AugmentedReality");

  public virtual void Execute(object cmdParams)
  {
    try
    {
      Mouse.OverrideCursor = System.Windows.Input.Cursors.Wait;
      Mouse.UpdateCursor();
      if (base.Push)
      {
        this._lifetimeManager.Stop();
      }
      else
      {
        if (this._lifetimeManager.Start())
          return;
        this.NotifySRConnectionProblem();
      }
    }
    finally
    {
      Mouse.OverrideCursor = (System.Windows.Input.Cursor) null;
      Mouse.UpdateCursor();
    }
  }

  private void NotifySRConnectionProblem()
  {
    int num = (int) TxMessageBox.Show(DnProcessSimulateCommands.DigitalTwinAlignment.Resources.Resources.UnableToStartSR, DnProcessSimulateCommands.DigitalTwinAlignment.Resources.Resources.BeamCommandName, MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
  }
}
